//Utility classes for XML files/structure
//TODO:  Add ability to parse text files and return a XMLNode object

#ifndef _HELIX_XML_UTIL_H_
#define _HELIX_XML_UTIL_H_

#include <string>
#include <list>
#include <vector>
#include <map>

#include "../Helix.h"
#include "../HObject.h"

using namespace std;

namespace helix
{

	class MY_CLASS XMLNode;

	//This class is used by XMLNode class to hold child XML nodes for an element
	class MY_CLASS XMLElementChildrenList : public HObject
	{
	private:
		vector<XMLNode*> *children;
	public:
		XMLElementChildrenList();
		~XMLElementChildrenList();

		void addChild(XMLNode *node);
		XMLNode *getChild(int index);
		int size();
	};

	//This class is used by XMLNode class to hold xml attributes for a node
	class MY_CLASS XMLElementAttributes : public HObject
	{
	private:
		map<string,string> *attributes;
	public:
		XMLElementAttributes();
		~XMLElementAttributes();

		void addAttribute(string attrib,string value);
		string getAttribute(string attrib);
		string getAttribute(int index);
		int size();
	};

	class MY_CLASS XMLNode : public HObject
	{
	private:
		string tagName;		//the type if xml element this is
		string value;
		XMLElementChildrenList *children;
		XMLElementAttributes *attributes;
	public:
		XMLNode();
		~XMLNode();

		void setTagName(string tagName);
		string getTagName();
		void setValue(string value);
		string getValue();
		int numChildren();
		int numAttributes();
		void addChild(XMLNode *node);
		void addAttribute(string attribute,string value);
		string getAttribute(string attribute);
		string getAttribute(int index);
		XMLNode * getChild(int index);
	};

}

#endif